/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package zonasoft.Manejadores;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import zonasoft.Conceptos.Especiales.Departamentos;

/**
 *
 * @author Usuario
 */
public class ManejadorDepartamentos {
     public static Connection con;
     public static Connection conm;

     
    private static List listaDepartamentos;
    public static List getDepartamentos(){
    return listaDepartamentos;
    }
    public static List listarDepartamentos() throws SQLException, Exception{
    ResultSet rs = null;
     PreparedStatement pst = null;
     listaDepartamentos = new LinkedList();
   try{
      pst = (PreparedStatement) con.prepareStatement(" SELECT * FROM `departamentos` ORDER BY `departamentos`.`nombre` ASC");



//       pst = con.prepareStatement("select * from departamentos");
     rs = pst.executeQuery();
     while (rs.next()){
         listaDepartamentos.add(Departamentos.load(rs));
            }
  } finally {
        if (rs != null) {
           rs.close();
       }
        if (pst != null) {
          pst.close();
       }
        return listaDepartamentos;
}

} // fin del listado


}// fin de la clase
